<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/view/common/header-company.jspf"%>
	<div class="alert alert-warning alert-dismissible" role="alert">
		<div style="width:200px;margin:0 auto;"><h1>企业主页</h1></div>
	</div>
<hr>
<div style="width:600px;margin:0 auto">
	<table class="table">
		<caption>
			<strong>一、职位管理：</strong><a
				href="<%=request.getContextPath()%>/view/company/position-add.jsp">发布职位</a>
		</caption>
		<thead>
			<tr>
				<th>编号</th>
				<th>职位名称</th>
				<th>薪资范围</th>
				<th>发布时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${positionList }" var="position" varStatus="v">
				<tr>
					<th scope="row">${v.count }</th>
					<td><a
						href="<%=request.getContextPath()%>/PositionServlet?command=preupdate&id=${position.id}">${position.name }</a></td>
					<td>${position.salary1 }-${position.salary2 }</td>
					<td><fmt:formatDate value="${position.releaseTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td><a
						href="<%=request.getContextPath()%>/PositionServlet?command=delete&id=${position.id}"
						onclick="return confirm('是否删除？');">删除</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<div style="width:900px;margin:0 auto">
	<table class="table">
		<caption>
			<strong>二、审核管理：</strong>
		</caption>
		<thead>
			<tr>
				<td colspan="7">
					<form id="conditionForm" action="<%=request.getContextPath() %>/ApplicationServlet?command=listCompanyVerify" method="post">
						职位名称：<input type="text" name="positionName" value="${applicationCondition.positionName }">
						审核状态：<select name="status">
									<option value="0">-全部-</option>
									<option value="1" <c:if test="${status == 1}">selected=selected</c:if>>待审核</option>
									<option value="2" <c:if test="${status == 2}">selected=selected</c:if>>已通过</option>
									<option value="3" <c:if test="${status == 3}">selected=selected</c:if>>已拒绝</option>
								</select>
						<button class="btn btn-primary">查询</button>
					</form>
				</td>
			</tr>
			<tr>
				<th>编号</th>
				<th>职位名称</th>
				<th>求职者</th>
				<th>简历信息</th>
				<th>申请时间</th>
				<th>审核状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${applicationList }" var="application" varStatus="v">
				<tr>
					<th scope="row">${v.count }</th>
					<td>${application.positionName }</td>
					<td>${application.talentName }</td>
					<td><a href="<%=request.getContextPath()%>/ResumeServlet?command=companyRead&id=${application.resumeId}&talentId=${application.talentId}">${application.resumeIntention }</a></td>
					<td><fmt:formatDate value="${application.appTime }"
							pattern="yyyy-MM-dd HH:mm:ss" /></td>
					<td>
						<c:if test="${application.status == 1 }">
							${application.statusStr }
						</c:if>
						<c:if test="${application.status != 1 }">
							${application.statusStr }
							(<fmt:formatDate value="${application.handleTime }" pattern="yyyy-MM-dd HH:mm:ss" />)
						</c:if>
						
					</td>
					<td><a
						href="javascript:verify(${application.id });">审核</a></td>
				</tr>
			</c:forEach>
			
		</tbody>
	</table>
</div>
<%@ include file="/view/common/footer.jspf"%>
<script>
	/**
	 * 信息提示框
	 */
	toastr.options = {
	  "closeButton": true,
	  "debug": false,
	  "positionClass": "toast-top-right",
	  "onclick": null,
	  "showDuration": "300",
	  "hideDuration": "1000",
	  "timeOut": "3000",
	  "extendedTimeOut": "1000",
	  "showEasing": "swing",
	  "hideEasing": "linear",
	  "showMethod": "fadeIn",
	  "hideMethod": "fadeOut"
	}
	if ('${success }') {
		toastr.success('${success }');
	}
	if ('${error }') {
		toastr.error('${error }');
	}
	
	/**
	 * 审核
	 */
	 function verify(applicationId) {
	    //询问框
	    layer.confirm('通过还是拒绝？', {
	    	closeBtn: 0,
	        icon : 3,
	        btn: ['通过','拒绝'] //按钮
	    }, function(){
	        layer.msg('您选择了通过！', {icon: 1, time: 1000});
	        location = '<%=request.getContextPath()%>/ApplicationServlet?command=verify&status=2&applicationId=' + applicationId;
	    }, function(){
	        layer.msg('您选择了拒绝！', {icon: 2, time: 1000});
	        location = '<%=request.getContextPath()%>/ApplicationServlet?command=verify&status=3&applicationId=' + applicationId;
	    });
	}
		
	/**
	 * 跳转到指定的页数
	 */
	function goPage(obj) {
		submitForm('<%=request.getContextPath()%>/ApplicationServlet?command=listCompanyVerifyByPage&pageNo=' + obj.value);
	}
	
	/**
	 * 分页时，使用JS使用表单
	 */
	function submitForm(url) {
		var conditionForm = document.getElementById('conditionForm');
		conditionForm.action = url;
		conditionForm.submit();
	}
</script>